package org.he.basic.util;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author He
 * @date 2023/11/28  20:03
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class AjaxResult {
    private Object data;
    private String msg;
    private Boolean success;

    public static AjaxResult success() {
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.success = true;
        ajaxResult.msg = "操作成功";
        return ajaxResult;
    }

    public static AjaxResult success(Object obj) {
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.success = true;
        ajaxResult.data = obj;
        ajaxResult.msg = "操作成功";
        return ajaxResult;
    }

    public static AjaxResult success(Object obj, String msg) {
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.success = true;
        ajaxResult.data = obj;
        ajaxResult.msg = msg;
        return ajaxResult;
    }

    public static AjaxResult error() {
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.msg = "操作失败";
        ajaxResult.success = false;
        return ajaxResult;
    }

    public static AjaxResult error(String msg) {
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.msg = msg;
        ajaxResult.success = false;
        return ajaxResult;
    }
}
